package workspace.teaweb.Logistics.controllers;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import workspace.teaweb.CRM.pojo.vo.CRMVO;
import workspace.teaweb.Logistics.pojo.dto.LogisticsGetDto;
import workspace.teaweb.Logistics.pojo.dto.LogisticsPostDto;
import workspace.teaweb.Logistics.pojo.entity.Logistics;
import workspace.teaweb.Logistics.service.LogisticsService;
import workspace.teaweb.base.response.JsonResult;

import javax.servlet.http.HttpSession;
import java.util.List;

@Validated//验证
@Slf4j
@Api(tags = "物流管理")
@RestController
@RequestMapping("/CRM/logistics")
public class LogisticsController {
    @Autowired
     LogisticsService logisticsService;


    @ApiOperation( "新增物流")
    @ApiOperationSupport(order = 10)
    @PostMapping("/insertlogistics")
    public JsonResult insertlogistics(@RequestBody Logistics logistics)
    {
        log.debug("物流信息添加:{}",logistics);
        logisticsService.insertlogistics(logistics);
        return JsonResult.ok(logistics);
    }
    @ApiOperation( "物流发货")
    @ApiOperationSupport(order = 20)
    @PostMapping("/updatePostlogistics")
    public JsonResult updatePostlogistics(@RequestBody LogisticsPostDto logistics)
    {
        log.debug("物流信息修改:{}",logistics);
        logisticsService.updatePostlogistics(logistics);
        return JsonResult.ok(logistics);
    }
    @ApiOperation( "物流到货")
    @ApiOperationSupport(order = 30)
    @PostMapping("/updateGetlogistics")
    public JsonResult updateGetlogistics(@RequestBody LogisticsGetDto logistics)
    {
        log.debug("物流信息修改:{}",logistics);
        logisticsService.updateGetlogistics(logistics);
        return JsonResult.ok(logistics);
    }
    @ApiOperation( "物流信息id查询")
    @ApiOperationSupport(order = 40)
    @GetMapping("/select/logisticsById")
    public JsonResult selectlogisticsById(Long id)
    {
        log.debug("物流信息查询:{}",id);
        Logistics logistics=logisticsService.selectlogisticsById(id);
        return JsonResult.ok(logistics);
    }
    @ApiOperation( "物流信息员工查询")
    @ApiOperationSupport(order = 50)
    @GetMapping("/select/logisticsByCRMid")
    public JsonResult selectlogisticsByCRMid(@RequestBody Logistics logistics)
    {
        log.debug("物流信息查询:{}",logistics);
        List<Logistics> logisticsvo=logisticsService.selectlogisticsByCRMid(logistics);
        return JsonResult.ok(logisticsvo);
    }

    @ApiOperation( "物流信息发货仓库状态")
    @ApiOperationSupport(order = 60)
    @GetMapping("/select/ByPostWarehouseidAndStatus")
    public JsonResult selectlogisticsByPostWarehouseidAndStatus(Long PostWarehouseid, String status)
    {
        Logistics logistics=logisticsService.selectlogisticsByPostWarehouseidAndStatus(PostWarehouseid,status);
        log.debug("物流信息查询:{}",logistics);
        return JsonResult.ok(logistics);
    }
    @ApiOperation( "物流信息到货仓库状态")
    @ApiOperationSupport(order = 70)
    @GetMapping("/select/ByGetWarehouseidAndStatus")
    public JsonResult selectlogisticsByGetWarehouseidAndStatus(Long GetWarehouseid, String status)
    {

        Logistics logistics=logisticsService.selectlogisticsByGetWarehouseidAndStatus(GetWarehouseid,status);
        log.debug("物流信息查询:{}",logistics);
        return JsonResult.ok(logistics);
    }


}
